package com.czkevin.wusan.tasks;

import com.czkevin.wusan.listeners.ItemSwitchListener;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

public class CheckEffectTask implements Runnable {
    @Override
    public void run() {
        Bukkit.getOnlinePlayers().forEach(this::check);
    }

    private void check(Player player) {
        if(ItemSwitchListener.checkWuSan(player.getInventory().getItemInMainHand()) ||
        ItemSwitchListener.checkWuSan(player.getInventory().getItemInOffHand())) {
            ItemSwitchListener.applyEffects(player);
        } else {
            ItemSwitchListener.removeEffects(player);
        }
    }
}
